import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int num;
        while ((num = in.nextInt())!= 0) { 
            System.out.println(getNum(num));
        }
    }

    public static int getNum(int num){
        int sum = 0;
        while(num > 1){
            sum += num / 3;
            num = num / 3 + num % 3;
            if(num == 2){
                sum++;
                break;
            }
        }
        return sum;
    }
}



